package com.elitel.frame.web.cfgtablefield.service.impl;

import com.elitel.frame.web.cfgtablefield.dao.CfgTableFieldDao;
import com.elitel.frame.web.cfgtablefield.entity.CfgTableField;
import com.elitel.frame.web.cfgtablefield.service.CfgTableFieldService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 元数据-字段信息表(CfgField)表服务实现类
 *
 * @author makejava
 * @since 2025-05-19 16:20:58
 */
@Service
public class CfgTableFieldServiceImpl implements CfgTableFieldService {
    @Resource
    private CfgTableFieldDao cfgTableFieldDao;

    /**
     * 通过ID查询单条数据
     *
     * @param guid 主键
     * @return 实例对象
     */
    @Override
    public CfgTableField queryById(String guid) {
        return this.cfgTableFieldDao.queryById(guid);
    }


    /**
     * 新增数据
     *
     * @param cfgTableField 实例对象
     * @return 实例对象
     */
    @Override
    public CfgTableField insert(CfgTableField cfgTableField) {
        this.cfgTableFieldDao.insert(cfgTableField);
        return cfgTableField;
    }

    /**
     * 修改数据
     *
     * @param cfgTableField 实例对象
     * @return 实例对象
     */
    @Override
    public CfgTableField update(CfgTableField cfgTableField) {
        this.cfgTableFieldDao.update(cfgTableField);
        return this.queryById(cfgTableField.getGuid());
    }

    /**
     * 通过主键删除数据
     *
     * @param guid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String guid) {
        return this.cfgTableFieldDao.deleteById(guid) > 0;
    }

    @Override
    public List<CfgTableField> list(CfgTableField cfgTableField) {
        return cfgTableFieldDao.queryList(cfgTableField);
    }
}
